package rs.dalao.syc.index.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import rs.dalao.syc.common.response.JsonResult;
import rs.dalao.syc.index.pojo.vo.*;
import rs.dalao.syc.index.service.IAidService;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/aid/")
@Api(tags = "4. 急救管理")
public class AidController {

    @Autowired
    private IAidService service;

    @GetMapping("/aidList/menu")
    @ApiOperation("急救指南一级目录信息")
    public JsonResult selectMenu(){
        List<AidMenuVO> aidMenuVOS = service.getAidMenu();
        return JsonResult.ok(aidMenuVOS);
    }

    @GetMapping("/aidList/{type}")
    @ApiOperation("急救百科keywords显示")
    @ApiOperationSupport(order = 201)
    public JsonResult getKeywords(@PathVariable Integer type) {
        log.debug("开始处理【急救百科keywords显示】的请求，参数：{}", type);
        List<AidKeywordsVO> getKeywords = service.getKeywords(type);
        return JsonResult.ok(getKeywords);
    }

    @GetMapping("{aidId}/detail")
    @ApiOperation("百科全书详情页面")
    public JsonResult selectByIdForDetail(@PathVariable Long aidId){
        List<AidDetailVO> aidDetailVOS = service.selectByIdForDetail(aidId);
        return JsonResult.ok(aidDetailVOS);
    }

    @GetMapping("detail/hot")
    @ApiOperation("展示急救热门文章")
    public JsonResult selectAidHotDetail(){
        List<HotDetailVO> aidHotDetailVOS = service.selectAidHotDetail();
        return JsonResult.ok(aidHotDetailVOS);
    }
}
